// DFS
#include<bits/stdc++.h>
using namespace std;
#define mm(a) memset(a, 0, sizeof(a))
const int MAXN = 22;
char mp[MAXN][MAXN];
int vis[MAXN][MAXN];
int d[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
int ans;
int W, H; // W = 6 H = 9
bool inArea(int x, int y) {
    return x >= 0 && x < H && y >= 0 && y < W;
}
void dfs(int x, int y) {
    if (!inArea(x, y)) return; // 越界返回
    if (mp[x][y] == '.' && vis[x][y] == 0) {
        ans++;
        vis[x][y] = 1;
    } else return;
    for (int i = 0; i < 4; i++) {
        int nx = x + d[i][0], ny = y + d[i][1];
        dfs(nx, ny);
    }
}

int main() {
    int x, y;
    while (cin >> W >> H) {
        ans = 0;
        if (W == 0 && H == 0) break;
        mm(vis);
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                cin >> mp[i][j];
                if (mp[i][j] == '@') {
                    x = i;
                    y = j;
                    mp[i][j] = '.';
                }
            }
        }
        dfs(x, y);
        cout << ans << endl;
    }
    return 0;
}